<?php
header('Content-Type:text/html;Charset=UTF-8');

@$name = $_REQUEST['name'];

@$age = $_REQUEST['age'];

@$sex = $_REQUEST['sex'];

@$contact = $_REQUEST['contact'];

@$address = $_REQUEST['address'];

@$img = $_REQUEST['img'];

$message ='';

if($img['error']!=0){
	$message=("照片上传出错");
}

$flag = move_uploaded_file($img['tmp_name'],'img/'.$img['name']);

if(!$flag){
	$message=("照片上传失败");
}

if (empty($name)){
	$message="姓名必需填写！";
	include "AddClient.php";
	die;
}
if (empty($age)||empty($sex)||empty($contact)||empty($address)){
	$message="年龄、姓名、联系方式、地址都必须填写！";
	include "AddClient.php";
	die;
}

require 'lib/db.php';

@$flag = dbInsert("insert into client(name,age,sex,contact,address,img) values(:name,:age,:sex,:contact,:address,:img)",array('name'=>$name,'age'=>$age,'sex'=>$sex,'contact'=>$contact,'address'=>$address,'img'=>$img['name']));


var_dump($flag);

// if ($flag==false){
// 	$message="客户添加失败！";
// 	include "AddClient.php";
// 	die;
// }else {
// 	header('Refresh:1;url=/AddClient.php');
// }





